package action.ShopAction;

import java.util.ArrayList;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.apache.struts2.ServletActionContext;

import com.opensymphony.xwork2.ActionSupport;

import domain.TransportInfo;
import domain.UserInfo;

public class OrderDetail extends ActionSupport {
	int Message_Id;
	public int getMessage_Id() {
		return Message_Id;
	}
	public void setMessage_Id(int messageId) {
		Message_Id = messageId;
	}
	public String execute() throws Exception {
		HttpSession session = ServletActionContext.getRequest().getSession();
		HttpServletRequest request=ServletActionContext.getRequest();
		UserInfo user = (UserInfo) session.getAttribute("UserLogin");
		ArrayList<TransportInfo> messages=(ArrayList<TransportInfo>)session.getAttribute("messages");
		TransportInfo message=new TransportInfo();
		for(int i=0;i<messages.size();i++){
			if(Message_Id==messages.get(i).getMessage_id()&&user.getUserId()==messages.get(i).getUser_Id())
			{
				message=messages.get(i);
				break;
			}
		}
		request.setAttribute("message", message);
		return SUCCESS;
	}
	
}
